﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Job.Web.Framework;
using Job.Entity;
using Job.Logic.BaseContent;
using Job.Logic.Personal;

namespace Job.Web.Person
{
    public partial class AddFavorites : BasePage
    {
        private string JobNo
        {
            get { return myR["job"].StringValue; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MySession session = new MySession();
                SessionPersonal person = session.GetPersonalFromSession();
                if ( null == person )
                {
                    ShowError("您只有登录后才能收藏职位！");
                    return;
                }

                if (JobNo.Length <= 0)
                {
                    ShowError("请指定需要收藏的猎头职位！");
                    return;
                }
                JobHunter job = new HunterJobLogic().GetDetail(JobNo);
                if (null == job)
                {
                    ShowError("您所指定的猎头职位已不存在！");
                    return;
                }

                JobPersonFavorites favorite = new JobPersonFavorites();
                favorite.JobId = job.JobId;
                favorite.PersonAccountId = person.PersonAccountid;
                new ApplyJobLogic().AddFavorite(favorite);

                lbJob.Text = "(" + job.JobNo + ") " + job.Name;
            }

        }

        private void ShowError(string message)
        {
            msgTd.InnerHtml = "<font color='#990000'>" + message + "</font>";
        }
    }
}
